Repository navigation
Add checks for valid response and retries to fetch_posts() - #481
Merged
Merged
Conversation
MarkKoz
previously approved these changes
Oct 2, 2019
MarkKoz
left a comment
Contributor
There was a problem hiding this comment.
It could still error out on content["data"]["children"] if it gets a JSON response in a format it doesn't expect, but at that point it's likely programmer error so the error should loudly present itself I think.
MarkKoz
dismissed
their stale review
October 2, 2019 05:05
On second thought, I think some logging would be good to have so that we aren't completely in the dark about invalid responses happening. Probably a debug log level is good enough.
MarkKoz
requested changes
Oct 2, 2019
MarkKoz
requested changes
Oct 3, 2019
MarkKoz
requested changes
Oct 3, 2019
Co-Authored-By: Mark <kozlovmark@gmail.com>
MarkKoz
approved these changes
Oct 3, 2019
MarkKoz
left a comment
Contributor
There was a problem hiding this comment.
I've tested this and it works great. Thanks!
Contributor
Author
|
Thanks Mark, that's exciting! Particularly because you've personally assisted me in the Discord more than once, haha. Cheers. |
sco1
approved these changes
Oct 3, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #390
Added checks for response.status and response.content_type for fetch_posts() to validate the response from self.bot.http_session.get(). Also added retries in case a bad response is received.
It's been tested to verify that the
!reddit top(and similar) commands still work, and I simulated some retry behavior by specifying intentionally bad routes. Please let me know what changes you'd like to see!